﻿using System;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.Exceptions;
using Autodesk.Revit.UI;
using HYView;

namespace HYRElectric.Command
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CmdChamferedWire : YJKCommandManual
	{
		protected override Result YJKExcute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			if (!(this.m_doc.ActiveView is ViewPlan))
			{
				Result result = SwitchView.SetUsableView((CmdViewType)3, cmdData);
				if (result != Result.Succeeded)
				{
					return result;
				}
			}
			RevitCommandId revitCommandId = RevitCommandId.LookupPostableCommandId(Autodesk.Revit.UI.PostableCommand.ChamferedWire);
			try
			{
				if (cmdData.Application.CanPostCommand(revitCommandId))
				{
					cmdData.Application.PostCommand(revitCommandId);
				}
			}
			catch (Autodesk.Revit.Exceptions.InvalidOperationException)
			{
				return Autodesk.Revit.UI.Result.Succeeded;
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
